<template>
  <el-container direction="vertical"
                class="contatiner">
    <el-form :model="loginForm"
             :rules="rules"
             ref="loginForm"
             label-position="left"
             label-width="0px"
             class="demo-ruleForm login-container">
      <h3 class="title">系统登录</h3>
      <el-form-item prop="user_login"
                    size="medium">
        <el-input type="text"
                  v-model="loginForm.user_login"
                  auto-complete="off"
                  placeholder="账号"></el-input>
      </el-form-item>
      <el-form-item prop="user_password"
                    size="medium">
        <el-input type="password"
                  v-model="loginForm.user_password"
                  auto-complete="off"
                  show-password
                  placeholder="密码"></el-input>
      </el-form-item>
      <div>
        <!-- <el-checkbox v-model="checked"
                     checked
                     class="remember">记住密码</el-checkbox> -->
        <!-- <div>
          ?忘记密码
        </div> -->
      </div>

      <el-form-item class="center"
                    size="medium">
        <el-button type="primary"
                   class="btnlogin"
                   @click.native.prevent="submitForm('loginForm')">登录</el-button>
        <!-- <el-button @click.native.prevent="handleReset">重置</el-button> -->
      </el-form-item>
    </el-form>
  </el-container>
</template>

<script>
//import NProgress from 'nprogress'
import { validateMobilePhone, validatePass, validateCode } from "../utils/tool";
import jsonp from "jsonp";
import md5 from "js-md5";
export default {
  data () {
    return {
      logining: false,
      loginForm: {
        user_login: "19999999999",
        user_password: "a123456",
      },
      rules: {
        user_login: [
          { required: true, message: "请输入账号", trigger: "blur" },
        ],
        user_password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { validator: validatePass, trigger: "blur" },
        ],
      },
      checked: true,
    };
  },
  created () { },
  methods: {
    handleReset () {
      this.$refs.loginForm.resetFields();
    },
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (formName == "loginForm") {
            //用户登录
            this.$api.admincustomer
              .customerlogin({
                customerPhone: this.loginForm.user_login,
                type: 1,
                password: this.loginForm.user_password, //md5()
              })
              .then((d) => {
                if (d.code == 200) {
                  this.$store.dispatch("set_token", d.data);
                  this.$router.push("/");
                } else {
                  this.$message.error(d.msg);
                }
              })
              .catch((e) => {
                // eslint-disable-next-line no-console
                console.log(e);
              });
          } else {
            this.next();
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    info () {
      this.$api.admincustomer
        .customerinfo({})
        .then((d) => {
          // console.log('sdafsdf', d);
          if (d.code == 200) {
            // console.log(d.data);
            this.$store.dispatch("set_token", d.data.token);
            this.$$store.dispatch("set_roleId", data.roleId)
            this.$router.push("/");
          } else {
            this.$message.error(d.msg);
          }
        })
        .catch((e) => {
          console.log(e);
        });
    },
  },
};
</script>

<style lang="scss">
.color4DBBCC {
  color: #4dbbcc;
}
html body,
contatiner {
  width: 100%;
  height: 100%;
  background-image: url(../img/bg.jpg);
  background-size: 150%;
}
.btnlogin {
  // width: 100%;
}
.login-container {
  /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #f5f5f5;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 5px #cac6c6;
  .title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
  .remember {
    margin: 0px 0px 35px 0px;
  }
}
</style>